/**
 *
 */
package anysware.source.dao.hibernate;

import java.util.Collection;

import org.hibernate.criterion.Restrictions;

import anysware.core.dao.hibernate.GenericHibernateDao;
import anysware.source.Source;
import anysware.source.dao.SourceDao;

/**
 * TODO: doc me
 *
 * @author keke<keke@codehaus.org>
 * @revision $Revision: 111 $
 * @version
 */
public class SourceHibernateDao extends GenericHibernateDao<Source, Long>
        implements SourceDao {

	public SourceHibernateDao() {
		super(Source.class);
	}

	public Source getSourceByName(final String name) {
		return (Source) currentSession().createCriteria(clazz).add(
		        Restrictions.eq("name", name)).setMaxResults(1).uniqueResult();
	}

	@SuppressWarnings("unchecked")
	public Collection<Source> getSourcesByType(final String type) {
		return currentSession().createCriteria(clazz).add(
		        Restrictions.eq("type", type)).list();
	}

}
